﻿<%@page
	import="com.hhit.collaborative_learning.dao.impl.PublicDaoImplMySql"%>
<%@page import="com.hhit.collaborative_learning.entity.BlogPage"%>
<%@page import="com.hhit.collaborative_learning.learning.StoreData"%>
<%@page import="java.util.Calendar"%>
<%@page import="com.hhit.collaborative_learning.utils.Utils"%>
<%@ page contentType="text/html; charset=utf-8" language="java"
	import="java.sql.*" errorPage=""%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%
	Calendar now = Calendar.getInstance();
	Utils.now = now;
	Utils.getSomedaysAgo(now);
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

	String orderby = request.getParameter("orderby");
	PublicDaoImplMySql dao = new PublicDaoImplMySql();
	BlogPage blogPage = dao.getBlog("", "", orderby);
	request.setAttribute("blogPage", blogPage);
	request.setAttribute("orderby", orderby);

	StoreData.getBlog(1);
	request.setAttribute("twoDays", StoreData.twoDaysBlog);

	StoreData.getBlog(2);
	request.setAttribute("newestRec", StoreData.newestRecommendBlog);

	if (StoreData.expertList == null) {
		StoreData.getExperts();
	}
	if (session.getAttribute("experts") == null) {
		session.setAttribute("experts", StoreData.expertList);
	}

	StoreData.getNewestExperts();
	request.setAttribute("newestExpert", StoreData.newestExperts);

	StoreData.getPrimeBlog();
	request.setAttribute("primeBlog", StoreData.primeBlog);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- <script id="allmobilize" charset="utf-8" -->
<!-- 	src="<%=basePath%>js/allmobilize.min.js"></script> -->
<!--new top-->
<link rel="stylesheet" href="<%=basePath%>css/index.css">
<!--new top-->

<link rel="Stylesheet" type="text/css" href="<%=basePath%>css/home.css" />
<script src="<%=basePath%>js/jquery.js" type="text/javascript"></script>
<script src="<%=basePath%>js/home.js" type="text/javascript"></script>
<script src="<%=basePath%>js/plugins.js" type="text/javascript"></script>
<script src="<%=basePath%>js/jquery.cookie.js" type="text/javascript"></script>
<!-- <script type="text/javascript" src="<%=basePath%>js/cnick.js"></script> -->
<script type='text/javascript'>
(function(){
$(function(){
	var back_top_value =Math.ceil(document.documentElement.clientHeight *0.65);
	var float_ask_img="<div data-mod='popu_64' class='tracking-ad' chg-blk='0' ><a id='com-d-top-a'  style='top:"+back_top_value+"px' title='返回顶部' onclick='' ></a> </div>";
	$("body").append(float_ask_img);
	
	var d_top = $('#com-d-top-a');

        $(document).scroll(function(){
            var scrTop = (document.body.scrollTop || document.documentElement.scrollTop);
            if (scrTop > 500)
            {
                d_top.show();
            } else
            {
                d_top.hide();
            }

        })
        $('#com-d-top-a').click(function ()
        {
            scrollTo(0, 0);
            this.blur();
            return false;
        });
});
})();
</script>
<link href="<%=basePath%>css/ask_float_block.css" type="text/css"
	rel="stylesheet" />
<script type="text/javascript">

	function addGuanZhu() {
		$.each($(".expert dt"), function(index, item) {
			var un = $(this).find("a").attr("un");
			$(this).append(
					'<a target="_top" href="javascript:void(0);" class="focus" un="'+un+'" link="<%=basePath%>learning/learning.jsp" onclick="checkLogin(this)" >关注</a>');
		});
	}

</script>
</head>
<body onload="addGuanZhu()">
	<div role="banner" class="blog-nav">
		<div class="container">
			<div role="navigation" class="navbar-collapse">
				<ul class="navbar-nav">
					<li class=active><a
						href="<%=basePath%>learning/learning.jsp" target="_top" title="">首页</a></li>
					<li><a href="<%=basePath%>learning/expert.jsp">博客专家</a></li>
					<li><a href="" class="rss" link="learning/myblog.jsp?page=bloglist" onclick="checkLogin(this)"
						target="_blank">我的专题</a></li>
					<li><a href="<%=basePath %>learning/search.jsp?type=1" target="_blank">搜索</a></li>
				</ul>
			</div>
		</div>
	</div>

	<div id="wrap">

		<div class="main_con">


			<div class="main_left">
				<div class="side_nav">
					<ul>
						<li class=select><a href="main_learning.jsp" target="_self"
							name="all">全部分类</a></li>
						<li><a href="<%=basePath%>GetBlogServlet?type=mobile"
							target="_self" name="mobile">移动开发</a></li>
						<li><a href="<%=basePath%>GetBlogServlet?type=web"
							target="_self" name="web">Web前端</a></li>
						<li><a href="<%=basePath%>GetBlogServlet?type=enterprise"
							target="_self" name="enterprise">架构设计</a></li>
						<li><a href="<%=basePath%>GetBlogServlet?type=code"
							target="_self" name="code">编程语言</a></li>
						<li><a href="<%=basePath%>GetBlogServlet?type=www"
							target="_self" name="www">互联网</a></li>
						<li><a href="<%=basePath%>GetBlogServlet?type=database"
							target="_self" name="database">数据库</a></li>
						<li><a href="<%=basePath%>GetBlogServlet?type=system"
							target="_self" name="system">系统运维</a></li>
						<li><a href="<%=basePath%>GetBlogServlet?type=cloud"
							target="_self" name="cloud">云计算</a></li>
						<li><a href="<%=basePath%>GetBlogServlet?type=software"
							target="_self" name="software">研发管理</a></li>
						<li><a href="<%=basePath%>GetBlogServlet?type=other"
							target="_self" name="other">综合</a></li>
					</ul>
				</div>

				<style type="text/css">
#home_cmd_col {
	padding: 0px 4px;
}

#home_cmd_col dt {
	width: 66px;
}

#home_cmd_col dt img {
	width: 64px;
	height: 64px;
}
</style>

				<div class="bor_box">
					<h1>推荐博客专家</h1>
					<dl class="experts">
						<dt>移动开发</dt>
						<dd>
							<ul>
								<c:forEach items="${sessionScope.experts.mobileExperts }"
									var="experts">
									<li><a href='personal.jsp?userId=${experts.userId }'
										target="_blank">${experts.userNickName }</a></li>
								</c:forEach>
							</ul>
						</dd>
						<dt>Web前端</dt>
						<dd>
							<ul>
								<c:forEach items="${sessionScope.experts.webExperts }"
									var="experts">
									<li><a href='personal.jsp?userId=${experts.userId }'
										target="_blank">${experts.userNickName }</a></li>
								</c:forEach>
							</ul>
						</dd>
						<dt>架构设计</dt>
						<dd>
							<ul>
								<c:forEach items="${sessionScope.experts.enterpriseExperts }"
									var="experts">
									<li><a href='personal.jsp?userId=${experts.userId }'
										target="_blank">${experts.userNickName }</a></li>
								</c:forEach>
							</ul>
						</dd>
						<dt>编程语言</dt>
						<dd>
							<ul>
								<c:forEach items="${sessionScope.experts.codeExperts }"
									var="experts">
									<li><a href='personal.jsp?userId=${experts.userId }'
										target="_blank">${experts.userNickName }</a></li>
								</c:forEach>
							</ul>
						</dd>
						<dt>互联网</dt>
						<dd>
							<ul>
								<c:forEach items="${sessionScope.experts.wwwExperts }"
									var="experts">
									<li><a href='personal.jsp?userId=${experts.userId }'
										target="_blank">${experts.userNickName }</a></li>
								</c:forEach>
							</ul>
						</dd>
						<dt>数据库</dt>
						<dd>
							<ul>
								<c:forEach items="${sessionScope.experts.databaseExperts }"
									var="experts">
									<li><a href='personal.jsp?userId=${experts.userId }'
										target="_blank">${experts.userNickName }</a></li>
								</c:forEach>
							</ul>
						</dd>
						<dt>系统运维</dt>
						<dd>
							<ul>
								<c:forEach items="${sessionScope.experts.systemExperts }"
									var="experts">
									<li><a href='personal.jsp?userId=${experts.userId }'
										target="_blank">${experts.userNickName }</a></li>
								</c:forEach>
							</ul>
						</dd>
						<dt>云计算</dt>
						<dd>
							<ul>
								<c:forEach items="${sessionScope.experts.cloudExperts }"
									var="experts">
									<li><a href='personal.jsp?userId=${experts.userId }'
										target="_blank">${experts.userNickName }</a></li>
								</c:forEach>
							</ul>
						</dd>
						<dt>研发管理</dt>
						<dd>
							<ul>
								<c:forEach items="${sessionScope.experts.softwareExperts }"
									var="experts">
									<li><a href='personal.jsp?userId=${experts.userId }'
										target="_blank">${experts.userNickName }</a></li>
								</c:forEach>
							</ul>
						</dd>
					</dl>
				</div>

			</div>
			<div class="main_center">

				<div class="blog_commend">
					<h3>
						<b class="tit">最新精华博文推荐</b>
					</h3>

					<ul>
						<c:forEach items="${requestScope.primeBlog }" var="blogs">
							<li><a
								href='<%=basePath%>learning/article.jsp?blogId=${blogs.blogId }&userId=${blogs.userId}&blogName=${blog.blogName}'
								target="_blank">${blogs.blogName }</a></li>
						</c:forEach>
					</ul>

					<h3>
						<b class="tit tit2">最新加入博客专家介绍</b>
					</h3>
					<c:forEach items="${requestScope.newestExpert}" var="newest">
						<dl class="expert">
							<dt>
								<a href="personal.jsp?userId=${newest.userId}" target="_blank"
									un="${newest.userId}"><img
									src="<%=basePath %>userIcons/${newest.userIcon}" width="48"
									height="48" /></a>
							</dt>
							<dd>
								<a href="personal.jsp?userId=${newest.userId}" target="_blank"
									un="${newest.userId}">${newest.userNickName}</a><br /> <span
									class="date">${newest.userBrief}</span>
							</dd>
						</dl>
					</c:forEach>
				</div>
				<div id="sub_tab">
					<a href="main_learning.jsp?orderby=time" target="_self"
						<c:if test="${requestScope.orderby eq 'time'}">class="curr"</c:if>>最新</a>
					<a href="main_learning.jsp" target="_self"
						<c:if test="${requestScope.orderby eq null || requestScope.orderby eq ''}">class="curr"</c:if>
						style="margin-right:2px;">最热</a>
				</div>
				<c:forEach items="${requestScope.blogPage.list }" var="blog">
					<div class="blog_list">
						<h1>
							<a href="<%=basePath%>GetBlogServlet?type=${blog.category}"
								class="category" target="_self">[${blog.category_CN}]</a> <a
								name="${blog.blogId }"
								href="<%=basePath%>learning/article.jsp?blogId=${blog.blogId }&userId=${blog.userId}&blogName=${blog.blogName}"
								target="_blank">${blog.blogName }</a>
						</h1>

						<dl>
							<dt>
								<a href="personal.jsp?userId=${blog.userId }" target="_blank">
									<img src="<%=basePath %>userIcons/${blog.userIcon}"
									alt="${blog.userId }" />
								</a>
							</dt>
							<dd>${blog.blogDesc }</dd>
						</dl>
						<p>
							
							<c:forEach items="${blog.tag }" var="tag">
								<a class="tag" href="javascript:void(0);">${tag }</a>
							</c:forEach>
						</p>
						<div class="about_info">
							<span class="fr digg" id="digg_${blog.blogId }"
								digg="${blog.goodNum }" bury="${blog.badNum }"></span> <span
								class="fl"> <a href="personal.jsp?userId=${blog.userId }"
								target="_blank" class="user_name">${blog.userName }</a> <span
								class="time">${blog.time }</span> <a
								href="<%=basePath%>learning/article.jsp?blogId=${blog.blogId }&userId=${blog.userId}&blogName=${blog.blogName}"
								target="_blank" class="view">阅读(${blog.readNum })</a> <a
								href="<%=basePath%>learning/article.jsp?blogId=${blog.blogId }&userId=${blog.userId}&blogName=${blog.blogName}&stepInto=comments"
								target="_blank" class="comment">评论(${blog.commentNum })</a>
							</span>
						</div>
					</div>
				</c:forEach>
				<div class="page_nav">
					<span> ${requestScope.blogPage.count }条数据
						共${requestScope.blogPage.totalPage }页</span>
					<c:if
						test="${requestScope.blogPage.pageDiffer*5+1<=requestScope.blogPage.totalPage}">
						<strong>${requestScope.blogPage.pageDiffer*5+1}</strong>
					</c:if>

					<c:if
						test="${requestScope.blogPage.pageDiffer*5+2<=requestScope.blogPage.totalPage}">
						<a target="_self"
							href="<%=basePath%>GetBlogServlet?currentPage=${requestScope.blogPage.pageDiffer*5+2}&orderby=${requestScope.orderby}">${requestScope.blogPage.pageDiffer*5+2}</a>
					</c:if>

					<c:if
						test="${requestScope.blogPage.pageDiffer*5+3<=requestScope.blogPage.totalPage}">
						<a target="_self"
							href="<%=basePath%>GetBlogServlet?currentPage=${requestScope.blogPage.pageDiffer*5+3}&orderby=${requestScope.orderby}">${requestScope.blogPage.pageDiffer*5+3}</a>
					</c:if>

					<c:if
						test="${requestScope.blogPage.pageDiffer*5+4<=requestScope.blogPage.totalPage}">
						<a target="_self"
							href="<%=basePath%>GetBlogServlet?currentPage=${requestScope.blogPage.pageDiffer*5+4}&orderby=${requestScope.orderby}">${requestScope.blogPage.pageDiffer*5+4}</a>
					</c:if>

					<c:if
						test="${requestScope.blogPage.pageDiffer*5+5<=requestScope.blogPage.totalPage}">
						<a target="_self"
							href="<%=basePath%>GetBlogServlet?currentPage=${requestScope.blogPage.pageDiffer*5+5}&orderby=${requestScope.orderby}">${requestScope.blogPage.pageDiffer*5+5}</a>
					</c:if>
					<c:if
						test="${requestScope.blogPage.totalPage>5 && requestScope.blogPage.pageDiffer<requestScope.blogPage.totalPage/5-1}">
						<a target="_self"
							href="<%=basePath%>GetBlogServlet?currentPage=${requestScope.blogPage.pageDiffer*5+6}&orderby=${requestScope.orderby}">...</a>
					</c:if>
					<c:if
						test="${requestScope.blogPage.currentPage<requestScope.blogPage.totalPage}">
						<a target="_self"
							href="<%=basePath%>GetBlogServlet?currentPage=${requestScope.blogPage.currentPage+1}&orderby=${requestScope.orderby}">下一页</a>
						<a target="_self"
							href="<%=basePath%>GetBlogServlet?currentPage=${requestScope.blogPage.totalPage}&orderby=${requestScope.orderby}">尾页</a>
					</c:if>
				</div>
			</div>
			<div class="main_right">
				<div class="write-boke">
					<a href="" onclick="checkLogin(this)" link="learning/myblog.jsp?page=postedit"
						target="_blank"></a>
				</div>
				<div class="boke-expert">
					<a href="" onclick="checkLogin(this)" link="learning/apply_expert.jsp" target="_blank"></a>
				</div>

				<div class="box_1">
					<h2>两天热门文章</h2>
					<ul class="list_2">
						<c:forEach items="${requestScope.twoDays }" var="blog">
							<li><a
								href="<%=basePath%>learning/article.jsp?blogId=${blog.blogId }&userId=${blog.userId}&blogName=${blog.blogName}"
								target="_blank" title="${blog.blogName }">${blog.blogName }</a></li>
						</c:forEach>
					</ul>
				</div>

				<style>
.main_right .box_1 {
	margin-top: 10px;
}
</style>
<script type="text/javascript">
	function checkLogin(e){
		var userId=$.cookie("userId");
		if(userId==null||userId.trim()==""){
			e.href="<%=basePath%>login.jsp?link="+encodeURIComponent($(e).attr("link"));
		}else{
			var un=$(e).attr("un");
			if(un){
				addFocus(un);
			}else{
				e.href="<%=basePath%>"+$(e).attr("link");
			}
		}
	}
	
	function addFocus(userId){
		$.post("<%=basePath%>AddFocusServlet",{userId:$.cookie("userId"),a_userId:userId,type:3},function(data,status){
			alert(data);
		});
	}
</script>
				<div class="box_1">
					<h2>最新推荐文章</h2>
					<ul class="list_2">
						<c:forEach items="${requestScope.newestRec }" var="blog">
							<li><a
								href="<%=basePath%>learning/article.jsp?blogId=${blog.blogId}&userId=${blog.userId}&blogName=${blog.blogName}"
								target="_blank" title="${blog.blogName }">${blog.blogName }</a></li>
						</c:forEach>
					</ul>
				</div>
			</div>

		</div>

	</div>

</body>
</html>
